var list=document.getElementById('list')
console.log(list)
onload=function(){
    loadData(0);
    add();
}

   




 function loadData(num){
     var num=num+1;

    var data=Ajax('GET','http://39.105.192.164:9090/apitest/goodslist','pager='+num)
    .then(function(data){
            //   console.log(data)
             data=JSON.parse(data).data.list
             
            list.innerHTML=''
         
             data.forEach(function(item){
       
            var li=document.createElement('li')
            str =`
            <a href='detali.html?id=${item.id}'>
                <img src='${item.pic}' class='pic'>
            </a>
                <p class='top'>${item.name}</p>
                <span>${item.price}元</span>

            `
            li.innerHTML=str
            list.appendChild(li)

            })

         })

 }






var p=document.getElementById('page').getElementsByTagName('li')
console.log(p)


function add(){
    
    for(let i=0;i<p.length;i++){
        p[i].onclick=function(){
            // console.log(i)
         loadData(i)
        }
    }
    
}

